package com.rao.gmall.item.comtroller;

import com.rao.gmall.common.result.Result;
import com.rao.gmall.feign.product.SpuFeignClient;
import com.rao.gmall.item.service.ItemService;
import org.redisson.api.RedissonClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author nzmxfan
 * @create 2021-08-06-12:45
 */
@RequestMapping("/api/item")
@RestController
public class SkuItemDetailController {

    @Resource
    ItemService itemService;

    /**
     * 获取sku详情信息:  聚合接口
     * @param skuId
     * @return
     */
    @GetMapping("/{skuId}")
    public Result getItem(@PathVariable("skuId") Long skuId){

        // itemService 远程调用 service-product 获取到当前商品的所有详情
        Map<String, Object> skuInfo = itemService.getSkuInfo(skuId);

        // 更新热度
        itemService.updateSkuHotScore(skuId);
        return Result.ok(skuInfo);
    }
}
